import request from '@/utils/request'

const orderService = {
  // 获取所有订单
  getOrders() {
    return request({
      url: '/Orders',
      method: 'get'
    })
  },

  // 根据ID获取订单
  getOrderById(id) {
    return request({
      url: `/Orders/${id}`,
      method: 'get'
    })
  },

  // 创建订单
  createOrder(data) {
    return request({
      url: '/Orders',
      method: 'post',
      data
    })
  },

  // 更新订单
  updateOrder(id, data) {
    return request({
      url: `/Orders/${id}`,
      method: 'put',
      data
    })
  },

  // 删除订单
  deleteOrder(id) {
    return request({
      url: `/Orders/${id}`,
      method: 'delete'
    })
  },

  // 更新订单状态
  updateOrderStatus(id, status) {
    return request({
      url: `/Orders/${id}/status`,
      method: 'put',
      params: { status }
    })
  },

  // 获取用户的订单列表
  getOrdersByUserId(userId) {
    return request({
      url: `/Orders/user/${userId}`,
      method: 'get'
    })
  },

  // 获取商品的订单列表
  getOrdersByProductId(productId) {
    return request({
      url: `/Orders/product/${productId}`,
      method: 'get'
    })
  }
}

export default orderService 